package com.huikaka.controller;

import com.huikaka.entity.Result;
import com.huikaka.entity.Shop;
import com.huikaka.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

//    获取所有的商家数据，除了店铺图片
    @GetMapping("/getAllShopInfoButPhoto")
    public Result test(){
        Result result = new Result();
        try {
            List<Shop> shopList = this.shopService.findAllShopInfoButPhoto();
            if (shopList != null){
                result.setCode(0);
                result.setMessage("成功");
                result.setData(shopList);
                result.setSize(shopList.size());
                return result;
            }
            result.setCode(1);
            result.setMessage("失败");
        }catch (Exception e){
            e.printStackTrace();
            result.setCode(3);
            result.setMessage("异常");
        }
        return result;
    }

}
